<?php


/** ensure this file is being included by a parent file */
defined('_JEXEC') or die('Restricted access');

		echo "<form action='{$this->formAction}' method='post' name='adminForm' id='adminForm' enctype='multipart/form-data'>";
		?>
		<table class="adminheading">
		<tr>
			<th class='helpdesk_fields'>
				<?php echo isset($this->pagetitle) ? $this->pagetitle : '' ?>
			</th>
		</tr>
		</table>

		<div id='onBeforeDisplay_wrapper'>
			<?php 
				$dispatcher = HelpDeskHelperPlugin::getInstance();
				$dispatcher->trigger( 'onBeforeDisplayFieldForm', array( $this->row, $this->user ) );
			?>
		</div>                

		<table class="invisible">
		<tbody>
		<tr>
			<td valign="top">
			<?php
				// display defaults
				$pane = '1';
				echo $this->sliders->startPane( "pane_$pane" );
				
				// DEFAULTS
				$legend = HelpDeskText::_( "Default Information" );
				echo $this->sliders->startPanel( HelpDeskText::_( $legend ), 'defaults' );
								
					echo '<table class="adminlist">';
					echo '<tr>';
		            	echo '<td class="title">';
							echo HelpDeskText::_( 'Title' ).' '.$this->required->image;
						echo '</td>';
		                echo '<td class="input">';
							echo "<input name='title' type='text' class='text_area' size='50' value='{$this->row->title}' />";
		                echo '</td>';
					echo '</tr>';
		
					echo '<tr>';
		            	echo '<td class="title">';
							echo HelpDeskText::_( 'Description' );
						echo '</td>';
		                echo '<td class="input">';
		                // TODO Use Editor?
		                	echo "<textarea name='description' cols='40' rows='10' style='width:500px' width='500px' >".stripslashes($this->row->description)."</textarea>";
		                echo '</td>';
					echo '</tr>';
					
					echo '<tr>';
		            	echo '<td class="title">';
							echo HelpDeskText::_( 'Published' );
						echo '</td>';
		                echo '<td class="input">';
							echo $this->select_published;
		                echo '</td>';
					echo '</tr>';
											
					echo '</table>';
					
				echo $this->sliders->endPanel();
				
				// DISPLAY
				$legend = HelpDeskText::_( "Display Settings" );
				echo $this->sliders->startPanel( HelpDeskText::_( $legend ), 'display' );
				?>
	                <table class="adminlist">
	                <tbody>
							<tr>
								<td class='title'>
									<?php echo HelpDeskText::_( 'Default' ); ?>:
								</td>
								<td class='input'>
									<textarea name="default" class="text_area" cols="40" rows="10" style="width:500px" width="500px" ><?php echo $this->row->default; ?></textarea>
								</td>
							</tr>
							<tr>
								<td class='title'>
									<?php echo HelpDeskText::_( 'Options' ); ?>:
								</td>
								<td class='input'>
									<textarea name="options" class="text_area" cols="40" rows="10" style="width:500px" width="500px" ><?php echo $this->row->options; ?></textarea>
								</td>
							</tr>
							<tr>
								<td class='title'>
									<?php echo HelpDeskText::_( 'Size' ); ?>:
								</td>
								<td class='input'>
									<input class="text_area" type="text" name="size" size="50" value="<?php echo $this->row->size;?>" />
								</td>
							</tr>
							<tr>
								<td class='title'>
									<?php echo HelpDeskText::_( 'Maximum Length' ); ?>:
								</td>
								<td class='input'>
									<input class="text_area" type="text" name="maxlength" size="50" value="<?php echo $this->row->maxlength;?>" />
								</td>
							</tr>
							<tr>
								<td class='title'>
									<?php echo HelpDeskText::_( 'Columns' ); ?>:
								</td>
								<td class='input'>
									<input class="text_area" type="text" name="cols" size="50" value="<?php echo $this->row->cols;?>" />
								</td>
							</tr>
							<tr>
								<td class='title'>
									<?php echo HelpDeskText::_( 'Rows' ); ?>:
								</td>
								<td class='input'>
									<input class="text_area" type="text" name="rows" size="50" value="<?php echo $this->row->rows;?>" />
								</td>
							</tr>
							<tr>
								<td class='title'>
									<?php echo HelpDeskText::_( 'Class' ); ?>:
								</td>
								<td class='input'>
									<input class="text_area" type="text" name="class" size="50" value="<?php echo $this->row->class;?>" />
								</td>
							</tr>
							<tr>
								<td class='title'>
									<?php echo HelpDeskText::_( 'Force Integer' ); ?>:
								</td>
								<td class='input'>
			                        <?php echo HelpDeskHTML::booleanList( 'integer', 'class="inputbox"', $this->row->integer ); ?>
								</td>
							</tr>
							<tr>
								<td class='title'>
									<?php echo HelpDeskText::_( 'Read Only' ); ?>:
								</td>
								<td class='input'>
			                        <?php echo HelpDeskHTML::booleanList( 'readonly', 'class="inputbox"', $this->row->readonly ); ?>
								</td>
							</tr>
							<tr>
								<td class='title'>
									<?php echo HelpDeskText::_( 'Parameters' ); ?>:
								</td>
								<td class='input'>
									<textarea name="params" class="text_area" cols="40" rows="10" style="width:500px" width="500px" ><?php echo $this->row->params; ?></textarea>
								</td>
							</tr>                  
	                </tbody>
	                </table>
				<?php
				echo $this->sliders->endPanel();
				
				// ADVANCED
				$legend = HelpDeskText::_( "Advanced Settings" );
				echo $this->sliders->startPanel( HelpDeskText::_( $legend ), 'advanced' );
				?>			
	                <table class="adminlist">
	                <tbody>
	                    <tr>
	                      	<td class='title' width="20%">
	                      		<?php echo HelpDeskText::_( 'Type' ); ?>: *
							</td>
	                        <td class="input">
		    	                <?php echo $this->select_typeid; ?>
	                        </td>
	                    </tr>
	                    <tr>
	                      	<td class='title' width="20%">
	                      		<?php echo HelpDeskText::_( 'Database Field Name' ); ?>:
							</td>
	                        <td class="input">
		    	                <?php echo $this->select_db_fieldname; ?>
	                        </td>
	                    </tr>
	                </tbody>
	                </table>
				<?php	
				echo $this->sliders->endPanel();
					
				// if there are plugins, display them accordingly
                if ($this->items_sliders) 
                {               	
                	$tab=1;
					$pane=2;
					for ($i=0, $count=count($this->items_sliders); $i < $count; $i++) {
						if ($pane == 1) {
							// echo $this->sliders->startPane( "pane_$pane" );
						}
						$item = $this->items_sliders[$i];
						echo $this->sliders->startPanel( HelpDeskText::_( $item->element ), $item->element );
						
						// load the plugin
							$import = HelpDeskHelperPlugin::importPlugin( strtolower( 'HelpDesk' ), $item->element );
						// fire plugin
							$dispatcher = HelpDeskHelperPlugin::getInstance();
							$dispatcher->trigger( 'onDisplayFieldFormSliders', array( $item, $this->row ) );
							
						echo $this->sliders->endPanel();
						if ($i == $count-1) {
							// echo $this->sliders->endPane();
						}
					}
				}
				
				echo $this->sliders->endPane();
				
				?>
			</td>
			<td valign="top">
			
				<div id='onDisplayRightColumn_wrapper'>
					<?php
						$dispatcher = HelpDeskHelperPlugin::getInstance();
						$dispatcher->trigger( 'onDisplayFieldFormRightColumn', array( $this->row, $this->user ) );
					?>
				</div>

			</td>
		</tr>
		</tbody>
		</table>

		<div id='onAfterDisplay_wrapper'>
			<?php 
				$dispatcher =& HelpDeskHelperPlugin::getInstance();
				$dispatcher->trigger( 'onAfterDisplayFieldForm', array( $this->row, $this->user ) );
			?>
		</div>
		
		<p>* <?php echo HelpDeskText::_( "or" )  . " " . $this->required->image . " " . HelpDeskText::_( 'Required Field' ); ?></p>

		<input type="hidden" name="option" value="<?php echo $this->formOption; ?>" />
		<input type="hidden" name="controller" value="<?php echo $this->formController; ?>" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="id" value="<?php echo $this->formId; ?>" />
		<input type="hidden" name="boxchecked" value="" />
		<input type="hidden" name="order" value="<?php echo $this->order; ?>" />
		<input type="hidden" name="order_dir" value="<?php echo $this->order_dir; ?>" />
        
		<?php
		echo $this->formValidate;
		echo "</form>";
		?>